/*
 * @Author: soon.liao
 * @Date: 2024-07-31 14:12:24
 * @LastEditors: soon.liao
 * @LastEditTime: 2024-07-31 15:06:42
 * @FilePath: \sdk_temp\applications\sample\wifi-iot\app\FastLED\src\platforms\hisilicon\hi3863\led_sysdefs_hi3863.h
 * @Description: NA
 * NA
 * Copyright (c) 2024 by soon.liao  , All Rights Reserved.
 */
#pragma once
#pragma message "HI3863 Hardware led sysdefs added"
#include "time.h"

#include "cmsis_os2.h"

#ifndef HI3863
#define HI3863
#endif

#define FASTLED_HI3863

//#define FASTLED_RISCV

#define FASTLED_NO_PINMAP

#define FASTLED_HAS_BLOCKLESS

#define FASTLED_ACCURATE_CLOCK

#ifndef F_CPU
#define F_CPU 240000000UL
#endif

// Use system millis timer
//#define FASTLED_HAS_MILLIS

typedef volatile uint32_t RoReg;
typedef volatile uint32_t RwReg;
typedef unsigned long prog_uint32_t;

// Default to NOT using PROGMEM here
#ifndef FASTLED_USE_PROGMEM
# define FASTLED_USE_PROGMEM 0
#endif

#ifndef FASTLED_ALLOW_INTERRUPTS
# define FASTLED_ALLOW_INTERRUPTS 1
# define INTERRUPT_THRESHOLD 0
#endif
#define FASTLED_SPI_BYTE_ONLY

#define FASTLED_ALL_PINS_HARDWARE_SPI

#define NEED_CXX_BITS

static unsigned long micros() {
    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    // 转换为微秒
    long microseconds = ts.tv_sec * 1000000L + ts.tv_nsec / 1000L;
    return microseconds;
}

static unsigned long millis(){
    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    long milliseconds = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
    return milliseconds;
}

static void yield(void) { osDelay(1U);}

// These can be overridden
#   define FASTLED_HI3863_RAW_PIN_ORDER

